package ankang.oop1;

public class CarTest {

    public static void main(String[] args) {
        //用变量c1代表创建的一个汽车对象
        Car    c1 = new Car();  //new Car()创建一个汽车对象。
        c1.color="blue";
        c1.brand="benz";
        c1.price=300000;
        c1.capacity=4;

        int c=c1.capacity;

        System.out.println(c1.capacity);

        c1.start();
        c1.run();
        c1.stop();
        String rs=c1.getMsg();
        System.out.println(rs);




        Person p1=new Person();//调用无参构造方法
        p1.name="小康";
        p1.age=18;
        p1.gender='男';

        boolean result=p1.eat();
        System.out.println("吃饱了没："+result);//false


        boolean result2=p1.eat();
        System.out.println("吃饱了没："+result2);//true


        boolean result3=false;

        for(int i=1; i<=8; i++) {
            result3 = p1.sleep();
        }
        System.out.println("是否睡够了" + result3);



        //成员变量不赋值，系统会赋默认值(整数赋值为0， 小数赋值为0.0，  boolean类型赋值为false，String赋值为null)




        //调用无参构造方法
        Person p2=new Person();
        //调用有参构造方法
        Person p3=new Person(18);




        Person p4=new Person();
        String msg4=p4.getAllMsg();
        System.out.println(msg4);

        Person p5=new Person(18);
        int age0=p5.age;
        System.out.println(age0);

        Person p6=new Person(20, '男');
        int p6Age=p6.age;
        System.out.println(p6Age);
        char p6Gender=p6.gender;
        System.out.println(p6Gender);


        Student s1=new Student();
        s1.stuNo="1001";

        String no=s1.stuNo;
        System.out.println(no);

        s1.name="小明";
        String n=s1.name;
        System.out.println(n);

        s1.study();

        s1.eat();

    }
}
